package top.xuwuqiang.study.jacawebjdbc.test.Jdbc;

import org.junit.jupiter.api.Test;
import top.xuwuqiang.study.jacawebjdbc.dao.DBHelper;
import top.xuwuqiang.study.jacawebjdbc.dao.TbMovieDAO;
import top.xuwuqiang.study.jacawebjdbc.entity.Tbmovie;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.List;
import java.util.Random;

public class Movietest {
    @Test
    public void insert()throws Exception{
        Random random=new Random();
        Tbmovie movie=new Tbmovie();
        movie.setMovie("电影"+random.nextInt());
        movie.setInfo("简介"+random.nextInt());
        movie.setScore(random.nextInt(10)+1);
        int iii= TbMovieDAO.insert(movie);
        System.out.println("添加的结果"+iii);
    }

    @Test
    public void query()throws Exception{
        List<Tbmovie>movies=TbMovieDAO.query();
        movies.forEach(movie->{
            System.out.println(movie);
        });
    }

    @Test
    public void delete()throws Exception{
        int i=TbMovieDAO.delete(1);
        System.out.println("删除的结果"+i);
    }
    }


